<?
define("KEY", "ABQIAAAAiO3_gTVoVOf54azjqgeqwxRubPjIgv94HjlpPsnPFzZEYPgt1hRyoBxPDjMI0E2s_YLcoU0NqRud6Q");
require_once('lib/db/db.php');
$db = new DBConnection('dbname=assclap_realty port=5432 user=assclap_assclap password=fibo1235');

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<LINK REL="SHORTCUT ICON" HREF="favicon.ico">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<!-- CSS -->
<style>
	@import "lib/jqPlugins/jQueryUI/css/trontastic/jquery-ui-1.8.7.custom.css";
	@import "lib/jqPlugins/jquery.layout.all-1.2.0/layout-default-latest.css";
	@import "css/earth.css";
</style>
<!-- End CSS -->
<!-- Javascript -->
<script type="text/javascript" src="http://www.google.com/jsapi?key=<? echo KEY; ?>"></script>
<!-- jQuery and plugins -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
<script type="text/javascript" src="lib/jqPlugins/jquery.cookie.js"></script>
<script type="text/javascript" src="lib/jqPlugins/jquery.layout.all-1.2.0/jquery.layout.min.js"></script>
<!-- Google Earth API extensions-->
<script type="text/javascript"  src="http://earth-api-utility-library.googlecode.com/svn/trunk/extensions/dist/extensions.pack.js"></script>
<script type="text/javascript"  src="lib/geometry_toolbox.js"></script>
<!-- App JS-->
<script type="text/javascript" src="js/earth-datatable.js"></script>
<script type="text/javascript" src="js/earth.js"></script>
<!-- End Javascript -->
<title>House Hunter Prototype</title>
</head>
<body onload='init()' >
<div id="container">
  <div class="pane ui-layout-center"><img src="../images/testpattern.jpg" style="height:100%; width:100%; z-index:-1; position:absolute" alt="" />
    <div id="map_canvas" style="border: 1px solid silver; "></div>
  </div>
  <div class="pane ui-layout-east">
    <div id="properties">
      <div class="ui-widget-header"><em>Search: </em>
        <input id="search" name="search" type="text" width="400px" /> 
        <em>Rating: </em>
        <select id="rating">
            <option value="">All</option>
            <option value="-2">Shithole: visited</option>
            <option value="-1">Not interested</option>
            <option value="0">Unrated</option>
            <option value="1">Flagged for visit</option>
            <option value="2">Visted and it's awesome</option>
        </select>
        <span id="filter_info"></span>
      </div>
    </div>
  </div>
  <div class="pane ui-layout-west">
    <div id="accordion">
      <h3><a href="#">Tools</a></h3>
      <div>
        <input type="checkbox" class="toggle-button" id="edit-mode" name="edit-mode" /><label for="edit-mode">Toggle Edit Mode</label>
        
        <a class="button" href="javascript:return false;" id="exportCSVForGARMIN">Export csv for Garmin</a>
        <a class="button" href="javascript:return false;" id="exportKMLForEarth">Export KML for Earth</a>
      </div>
      <h3><a href="#">Layers</a></h3>
      <div>
        <?
	
	$sql = "select distinct * from overlay";
	$Query = $db->CreateQuery($sql);
	while($row = $Query->FetchObject())
	{
	?>
					<div class="checkdiv"><input type="checkbox" class="layerCheck" name="<? echo urlencode($row->name); ?>" id="<? echo urlencode($row->name); ?>" value="<? echo urlencode($row->url); ?>" <? if(isset($_COOKIE['Layer' .  urlencode($row->name)])) echo "checked"; ?> /><label for="<? echo urlencode($row->name); ?>"><? echo "$row->name"; ?></label></div>
	<?
	}
	?>

      </div>
      <h3><a href="#">Filter by Zip</a></h3>
      <div>
        <?
	$sql = "select distinct zip, city, count(*) as cunt from property where zip is not null and zip <> '' group by zip, city order by cunt desc";
	$Query = $db->CreateQuery($sql);
	while($row = $Query->FetchObject())
	{
	?>
	<div class="divCheck"><input type="checkbox" class="zipCheck" name="check<? echo urlencode($row->zip); ?>" id="check<? echo urlencode($row->zip); ?>" value="<? echo $row->zip; ?>" <? if(isset($_COOKIE['check' . urlencode($row->zip)])) echo "checked"; ?> /><label for="check<? echo urlencode($row->zip); ?>"><? echo "$row->zip ($row->city) ($row->cunt)"; ?></label></div>
	<?
	}
	?>

      </div>
      <h3><a href="#">Filter by City</a></h3>
      <div>
		<?
	$sql = "select distinct city, count(*) as cunt from property where city is not null and city <> '' group by city order by cunt desc";
	$Query = $db->CreateQuery($sql);
	while($row = $Query->FetchObject())
	{
        ?>
                        <div class="checkdiv"><input type="checkbox" class="cityCheck" name="check<? echo urlencode($row->city); ?>" id="check<? echo urlencode($row->city); ?>" value="<? echo $row->city; ?>" <? if(isset($_COOKIE['check' .  urlencode($row->city)])) echo "checked"; ?> /><label for="check<? echo urlencode($row->zip); ?>"><? echo "$row->city, ($row->cunt)"; ?></label></div>
        <?
	}
        ?>
      </div>
    </div>
  </div>
</div>
<div id="logo" class="ui-widget-header">House Hunter Prototype<br />
<span id="sql"></span></div>
<div id="secret_stash" style="visibility:hidden; display:none">
<? include('lib/propertywindow.php'); ?>
</div>
<div id="modal_overlay" class="ui-widget-overlay">
	<div id="message" class="ui-corner-all ui-dialog">
    	<div id="text"></div>
    	<div id="progressbar" class=""></div>
    </div>
</div>
</body>
</html>